package com.example.mobile2021606176mhq0330;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private EditText editTextMainAccount;
    private EditText editTextMainPsw;
    private Button btnMainLogin;
    private Button btnMainReset;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String account = editTextMainAccount.getText().toString();
                String password = editTextMainPsw.getText().toString();

                if (account.length() == 0) {
                    Log.i("登录", "请输入用户名");
                } else if (password.length() == 0){
                    Log.i("登录", "请输入密码");
                }else {


                    if (account.equals("admin") & password.equals("123456")) {
                        Log.i("登录", "登录成功");
                    } else {
                        Log.i("登录", "登录失败");
                    }
                    editTextMainAccount.setText(null);
                    editTextMainPsw.setText(null);
                }
            }
        });
        btnMainReset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                editTextMainAccount.setText(null);
                editTextMainPsw.setText(null);
            }

            });
        }{;
}
        private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        editTextMainAccount = (EditText) findViewById(R.id.editText_main_account);
        editTextMainPsw = (EditText) findViewById(R.id.editText_main_psw);
        btnMainLogin = (Button) findViewById(R.id.btn_main_login);
        btnMainReset = (Button) findViewById(R.id.btn_main_reset);
    }
}